export enum ContextMenuId {
  /** 将当前网址标记为 swagger 文档 */
  MARKE_AS_SWAGGER = 'marke-as-swagger',
  /** 打开 options 页面 */
  OPEN_OPTIONS = 'open-options-page',
  /** 查看当前接口的类型 */
  PREVIEW = 'preview',
  CONSOLE_GROUP = 'console.group',
  CONSOLE_GROUP_COOLAPSED = 'console.groupCollapsed',
  /** 写入粘贴板 */
  CLIPBOARD_WRITE_TEXT = 'clipboard.writeText'
}

export enum PostMessageType {
  /** 建立通信 */
  CONNECT = 'connect',
  /** 上下文菜单 */
  CONTEXT_MENU = 'contextmenu',
  /** data */
  DATA = 'data',
  /** 心跳检查 */
  HEARTBEAT = 'heartbeat'
}

export interface PostMessageEventInterface {
  uniqueId?: string
  type?: any
  data?: any
}

export interface ConnectPostMessageEvent extends PostMessageEventInterface {
  type: PostMessageType.CONNECT
  data: string
}

export interface ContextMenuPostMessageEvent extends PostMessageEventInterface {
  type: PostMessageType.CONTEXT_MENU
  data: ContextMenuId
}

export interface DataPostMessageEvent<T = any> extends PostMessageEventInterface {
  type: PostMessageType.DATA
  data: T
}

export interface HeartbeatPostMessageEvent<T = any> extends PostMessageEventInterface {
  type: PostMessageType.HEARTBEAT
}

export type PostMessageEvent =
  | ConnectPostMessageEvent
  | ContextMenuPostMessageEvent
  | DataPostMessageEvent
  | HeartbeatPostMessageEvent

export interface DcosApiStorageItem {
  title: string
  origin: string
  pathname: string
}

export interface CSSObject {
  value: string
  css: string
}

export interface StorageStore {
  docsApis: DcosApiStorageItem[]
  cssInjectActive: string
  cssInjectList: CSSObject[]
}

export enum Certificate {
  NONE,
  CONTENT
}
